Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent MoveBucket from moving a bucket across two different db files #671

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

Elbehery
Copy link
Member

@Elbehery Elbehery commented Jan 9, 2024

This PR adds more test to move bucket feature

  • Test moving buckets between two different database files
  • Test moving buckets using two different transactions

Refer to #635 (comment)

cc @ahrtr @fuweid

movebucket_test.go Outdated Show resolved Hide resolved
movebucket_test.go Outdated Show resolved Hide resolved
@ahrtr
Copy link
Member

ahrtr commented Jan 10, 2024

Let's add 3 cases below,

  • The source tx is readonly, the target tx is readwrite; both are for the same db;
  • The source tx is readwrite, and the target tx is readonly; both are for the same db;
  • The source bucket and target bucket are not in the same db.

errors/errors.go Outdated Show resolved Hide resolved
bucket.go Outdated Show resolved Hide resolved
@ahrtr ahrtr changed the title add more test movebucket Prevent MoveBucket from moving a bucket across two different db files Jan 10, 2024
@ahrtr ahrtr added this to the v1.4.0 milestone Jan 10, 2024
@Elbehery Elbehery force-pushed the add_move_bucket_protection branch 2 times, most recently from c055ad5 to ff0b03b Compare January 10, 2024 21:36
@Elbehery
Copy link
Member Author

Let's add 3 cases below,

  • The source tx is readonly, the target tx is readwrite; both are for the same db;
  • The source tx is readwrite, and the target tx is readonly; both are for the same db;
  • The source bucket and target bucket are not in the same db.

done 👍🏽

@ahrtr
Copy link
Member

ahrtr commented Jan 11, 2024

@Elbehery
Please take a look at the workflow failure, thx

@Elbehery
Copy link
Member Author

@Elbehery Please take a look at the workflow failure, thx

fixed .. my bad, forgot to close the second db file :'(

deep apologies

movebucket_test.go Outdated Show resolved Hide resolved
@Elbehery
Copy link
Member Author

i got it, i used the wrong var to in the defer :'(

movebucket_test.go Outdated Show resolved Hide resolved
movebucket_test.go Outdated Show resolved Hide resolved
movebucket_test.go Outdated Show resolved Hide resolved
movebucket_test.go Outdated Show resolved Hide resolved
movebucket_test.go Outdated Show resolved Hide resolved
movebucket_test.go Outdated Show resolved Hide resolved
movebucket_test.go Outdated Show resolved Hide resolved
movebucket_test.go Outdated Show resolved Hide resolved
@ahrtr
Copy link
Member

ahrtr commented Jan 12, 2024

@Elbehery Please let's try to get this PR merged today before I create the tag 1.4.0-alpha.0

@Elbehery
Copy link
Member Author

@ahrtr updated & rebased 👍🏽

err = dstDB.Update(func(tx *bbolt.Tx) error {
dstBucket := prepareBuckets(t, tx, dstBucketPath...)
mErr := srcBucket.MoveBucket([]byte(bucketToMove), dstBucket)
require.Equal(t, expectedErr, mErr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment:

Suggested change
require.Equal(t, expectedErr, mErr)
require.Equal(t, errors.ErrDifferentDB, mErr)

srcBucketPath := []string{"sb1", "sb2"}
dstBucketPath := []string{"db1", "db2"}
bucketToMove := "bucketToMove"
expectedErr := errors.ErrDifferentDB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expectedErr := errors.ErrDifferentDB

Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
@Elbehery
Copy link
Member Author

@ahrtr updated

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Thanks

@ahrtr ahrtr merged commit 2c1cba7 into etcd-io:main Jan 12, 2024
16 checks passed
@ahrtr ahrtr removed this from the v1.4.0 milestone Jan 12, 2024
@Elbehery Elbehery deleted the add_move_bucket_protection branch January 12, 2024 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants